#!/bin/bash
# 公共配置变量，供所有脚本使用

# 基础目录设置
Basedir="/data/app"
APPS_HOME="/data/app/download"
Basebin="/usr/local/bin"

# 下载地址前缀
TOMCAT_NAME="https://dlcdn.apache.org/tomcat/tomcat-"
REDIS_NAME="http://download.redis.io/releases/redis-"
NODE_NAME="https://cdn.npmmirror.com/binaries/node/"
NGINX_NAME="https://nginx.org/packages/centos/7/x86_64/RPMS/nginx-"
NGINX_NAME_END="-1.el7.ngx.x86_64.rpm"
MYSQL_NAME="https://repo.mysql.com/yum/mysql-"
MYSQL_NAME_END="-community/el/7/x86_64/mysql-community-"
MONGODB_NAME="https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-"
MAVEN_NAME="https://mirrors.aliyun.com/apache/maven/maven-"
GOLANG_NAME="https://mirror.go-repo.io/centos/7/x86_64/golang-"
GOLANG_END="-0.el7.x86_64.rpm "
GRAFANA_NAME="https://dl.grafana.com/enterprise/release/grafana-enterprise-"

# 服务文件路径
TOMCAT_SERVICE="/etc/systemd/system/tomcat.service"
REDIS_SERVICE="/etc/systemd/system/redis.service"
MONGODB_SERVICE="/etc/systemd/system/mongodb.service"
NGINX_SERVICE="/etc/systemd/system/nginx.service"
MYSQL_SERVICE="/etc/systemd/system/mysqld.service"

# 创建应用目录
function app_home() {
    if [ ! -d "${APPS_HOME}" ] ; then
        echo "目录${APPS_HOME}不存在，已创建"
        mkdir -p ${APPS_HOME}
    fi
}

# 错误处理函数
function error_exit() {
    echo -e "\033[31m$1\033[0m"
    exit 1
}

# 成功提示函数
function success_msg() {
    echo -e "\033[32m$1\033[0m"
}
